package com.alks.function.controller;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.PcLotExp2Request;
import com.alks.function.service.PcLotExp2Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;

@ApiRestController("/change")
@Api(tags = "指令变更记录")
public class PcLotExp2Controller {

    @Autowired
    private PcLotExp2Service pcLotExp2Service;

    @WebLogger
    @PostMapping("/getVersion")
    @ApiOperation("选择版本")
    public ResponseInfo getVersion(@RequestBody PcLotExp2Request request){
        return pcLotExp2Service.getVersions(request);
    }

    @WebLogger
    @GetMapping("/getUsageDifference")
    @ApiOperation("指令用量差异")
    public ResponseInfo getUsageDifference(@RequestParam String lotNo,@RequestParam Integer version){
        return pcLotExp2Service.getInstructUsageDifference(lotNo,version);
    }

    @WebLogger
    @GetMapping("/getWheelMaterialUsageDifference")
    @ApiOperation("子材料用量差异")
    public ResponseInfo getWheelMaterialUsageDifference(@RequestParam String mtlNo,@RequestParam Integer version,@RequestParam Integer seqNo,@RequestParam String lotNo){
        return pcLotExp2Service.getWheelMaterialUsageDifference(mtlNo,version,seqNo,lotNo);
    }

    @GetMapping("/getStyle2Color")
    @WebLogger
    @ApiOperation("指令用量差异计算返回型体颜色")
    public ResponseInfo getStyle2Color(@RequestParam String lotNo){
        return pcLotExp2Service.getStyle2Color(lotNo);
    }

    @GetMapping("/getConditionBox")
    @WebLogger
    @ApiOperation("指令用量差异返回条件")
    public ResponseInfo getConditionBox(){
        return pcLotExp2Service.getConditionBox();
    }

    @GetMapping("/exportChange")
    @WebLogger
    @ApiOperation("导出明细")
    public void exportChange(@RequestParam String lotNo, @RequestParam Integer version, HttpServletResponse response){
        pcLotExp2Service.exportChange(lotNo,version,response);
    }
}
